/**
 * create by young (young2f@outlook.com) on 2020/12/4
 * 考勤
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    code: {
      type: String,
      _type: 'code',
      title: '员工编码',
      required: true,
      enableArea: [ 'table', 'detail', 'search' ]
    },
    division: {
      type: String,
      _type: 'code',
      title: '公司',
      required: true,
      enableArea: [ 'table', 'detail', 'search' ]
    },
    name: { type: String, _type: 'string', title: '姓名', required: true, enableArea: [ 'table', 'detail', 'search' ] },
    department: {
      type: String,
      _type: 'string',
      title: '部门',
      required: true,
      enableArea: [ 'table', 'detail', 'search' ]
    },
    level: {
      type: String,
      _type: 'string',
      title: '职级',
      required: true,
      enableArea: [ 'table', 'detail', 'search' ]
    },
    inDate: {
      type: Date,
      _type: 'date',
      title: '入职时间',
      required: true,
      enableArea: [ 'table', 'detail', 'search' ]
    },
    xlFileList: { type: Array, _type: 'fileList', title: '学历证书' },
    htFileList: { type: Array, _type: 'fileList', title: '人事合同' },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('Personnel', _schema);
};
